<?php

namespace app\manystore\Logc;

use app\api\Logic\Pay\PayLogic;
use app\api\model\PayLog;

class PayLogic
{
    //下单插入订单总表
    public function pay()
    {
        $data = $this->request->param();

        $orderId = $this->payLogic->createOrder($data);
        if($orderId){
            $this->success('插入成功',['order_id' => $orderId]);
        }
        $this->error('插入失败');
    }

    //订单支付回调
    public function pay_result($order_sn){
        $pay_log = PayLogModel::where('order_sn',$order_sn)->find();
        if(empty($pay_log)){
            $this->error('订单不存在');
        }
        //判断订单类型 各自支付回调
        switch ($pay_log['controller']){
            case '订单类型':
                action('manystore/' . $pay_log['controller'] . '/pay_result', [$pay_log['id']]);
                break;
            default:
                break;
        }
    }
}
